package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WdyTradeRecord;
import com.ruoyi.system.service.IWdyTradeRecordService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 成交记录 信息操作处理
 * 
 * @author ruoyi
 * @date 2020-01-06
 */
@Controller
@RequestMapping("/system/wdyTradeRecord")
public class WdyTradeRecordController extends BaseController
{
    private String prefix = "system/wdyTradeRecord";
	
	@Autowired
	private IWdyTradeRecordService wdyTradeRecordService;
	
	@RequiresPermissions("system:wdyTradeRecord:view")
	@GetMapping()
	public String wdyTradeRecord()
	{
	    return prefix + "/wdyTradeRecord";
	}
	
	/**
	 * 查询成交记录列表
	 */
	@RequiresPermissions("system:wdyTradeRecord:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(WdyTradeRecord wdyTradeRecord)
	{
		startPage();
        List<WdyTradeRecord> list = wdyTradeRecordService.selectWdyTradeRecordList(wdyTradeRecord);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出成交记录列表
	 */
	@RequiresPermissions("system:wdyTradeRecord:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WdyTradeRecord wdyTradeRecord)
    {
    	List<WdyTradeRecord> list = wdyTradeRecordService.selectWdyTradeRecordList(wdyTradeRecord);
        ExcelUtil<WdyTradeRecord> util = new ExcelUtil<WdyTradeRecord>(WdyTradeRecord.class);
        return util.exportExcel(list, "wdyTradeRecord");
    }
	
	/**
	 * 新增成交记录
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存成交记录
	 */
	@RequiresPermissions("system:wdyTradeRecord:add")
	@Log(title = "成交记录", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(WdyTradeRecord wdyTradeRecord)
	{		
		return toAjax(wdyTradeRecordService.insertWdyTradeRecord(wdyTradeRecord));
	}

	/**
	 * 修改成交记录
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		WdyTradeRecord wdyTradeRecord = wdyTradeRecordService.selectWdyTradeRecordById(id);
		mmap.put("wdyTradeRecord", wdyTradeRecord);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存成交记录
	 */
	@RequiresPermissions("system:wdyTradeRecord:edit")
	@Log(title = "成交记录", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(WdyTradeRecord wdyTradeRecord)
	{		
		return toAjax(wdyTradeRecordService.updateWdyTradeRecord(wdyTradeRecord));
	}
	
	/**
	 * 删除成交记录
	 */
	@RequiresPermissions("system:wdyTradeRecord:remove")
	@Log(title = "成交记录", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(wdyTradeRecordService.deleteWdyTradeRecordByIds(ids));
	}
	
}
